home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / machine / foodf.c < prev    next >
C/C++ Source or Header  |  2000-04-04  |  2KB  |  123 lines

  1. /*************************************************************************
  2.  
  3.   Food Fight machine hardware
  4.  
  5. *************************************************************************/
  6.  
  7. #include <stdlib.h>
  8. #include "driver.h"
  9.  
  10.  
  11.  
  12.  
  13. /*
  14.  *        Statics
  15.  */
  16.  
  17. static int whichport = 0;
  18.  
  19.  
  20. /*
  21.  *        Interrupt handlers.
  22.  */
  23.  
  24. void foodf_delayed_interrupt (int param)
  25. {
  26.     cpu_cause_interrupt (0, 2);
  27. }
  28.  
  29. int foodf_interrupt (void)
  30. {
  31.     /* INT 2 once per frame in addition to... */
  32.     if (cpu_getiloops () == 0)
  33.         timer_set (TIME_IN_USEC (100), 0, foodf_delayed_interrupt);
  34.  
  35.     /* INT 1 on the 32V signal */
  36.     return 1;
  37. }
  38.  
  39.  
  40. /*
  41.  *        NVRAM read/write.
  42.  *      also used by Quantum
  43.  */
  44.  
  45. static unsigned char nvram[128];
  46.  
  47. READ_HANDLER( foodf_nvram_r )
  48. {
  49.     return ((nvram[(offset / 4) ^ 0x03] >> 2*(offset % 4))) & 0x0f;
  50. }
  51.  
  52.  
  53. WRITE_HANDLER( foodf_nvram_w )
  54. {
  55.     nvram[(offset / 4) ^ 0x03] &= ~(0x0f << 2*(offset % 4));
  56.     nvram[(offset / 4) ^ 0x03] |= (data & 0x0f) << 2*(offset % 4);
  57. }
  58.  
  59. void foodf_nvram_handler(void *file,int read_or_write)
  60. {
  61.     if (read_or_write)
  62.         osd_fwrite(file,nvram,128);
  63.     else
  64.     {
  65.         if (file)
  66.             osd_fread(file,nvram,128);
  67.         else
  68.             memset(nvram,0xff,128);
  69.     }
  70. }
  71.  
  72.  
  73. /*
  74.  *        Analog controller read dispatch.
  75.  */
  76.  
  77. READ_HANDLER( foodf_analog_r )
  78. {
  79.     switch (offset)
  80.     {
  81.         case 0:
  82.         case 2:
  83.         case 4:
  84.         case 6:
  85.             return readinputport (whichport);
  86.     }
  87.     return 0;
  88. }
  89.  
  90.  
  91. /*
  92.  *        Digital controller read dispatch.
  93.  */
  94.  
  95. READ_HANDLER( foodf_digital_r )
  96. {
  97.     switch (offset)
  98.     {
  99.         case 0:
  100.             return input_port_4_r (offset);
  101.     }
  102.     return 0;
  103. }
  104.  
  105.  
  106. /*
  107.  *        Analog write dispatch.
  108.  */
  109.  
  110. WRITE_HANDLER( foodf_analog_w )
  111. {
  112.     whichport = 3 - ((offset/2) & 3);
  113. }
  114.  
  115.  
  116. /*
  117.  *        Digital write dispatch.
  118.  */
  119.  
  120. WRITE_HANDLER( foodf_digital_w )
  121. {
  122. }
  123.